﻿using Abp.Web.Mvc.Controllers;
using GN.Pay.Core;
using System.Web.Mvc;

namespace GN.Pay.GatewayWeb.Controllers
{
    /// <summary>
    /// Derive all Controllers from this class.
    /// </summary>
    public abstract class PayControllerBase : AbpController
    {
        protected PayControllerBase()
        {
            LocalizationSourceName = Consts.LocalizationSourceName;
        }

        /// <summary>
        /// 错误视图
        /// </summary>
        /// <param name="title"></param>
        /// <param name="errorTitle"></param>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        protected ActionResult ErrorView(string title, string errorTitle, string errorMessage)
        {
            ViewBag.Title = title;
            ViewBag.ErrorTitle = errorTitle;
            ViewBag.ErrorMessage = errorMessage;
            // ViewBag.ErrorInfo = new { Title = errorTitle, Message = errorMessage };
            return View("Error");
        }

        /// <summary>
        /// Wap错误视图
        /// </summary>
        /// <param name="title"></param>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        protected ActionResult WapErrorView(string title, string errorMessage)
        {
            ViewBag.Title = title;
            ViewBag.ErrorMessage = errorMessage;
            return View("WapError");
        }

        private const string QueryErrorMessage = "查询出现异常,可能服务器太忙！若已成功支付，请查询相应的订单查看状态";

        /// <summary>
        /// 错误视图
        /// </summary>
        /// <returns></returns>
        protected ActionResult ErrorView()
        {
            return this.ErrorView("提示", "交易提示", QueryErrorMessage);
        }

        /// <summary>
        /// 错误视图
        /// </summary>
        /// <returns></returns>
        protected ActionResult WapErrorView()
        {
            return this.WapErrorView("交易提示", "无法获取通知信息，若已确认支付请前往订单中心查看(4)。");
        }
    }
}